package ${packageName}.controller;

import com.water.conservancy.common.core.domain.R;
import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestBody;
import ${packageName}.domain.${entityName};
import ${packageName}.dto.req.add.${addReqDto};
import ${packageName}.dto.req.update.${updateReqDto};
import ${packageName}.dto.req.query.${queryPageReqDto};
import ${packageName}.dto.res.${queryResDto};
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
import ${packageName}.service.${serviceName};
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@Api(value = "${tableComment}", tags = "${tableComment}")
@RequestMapping("/${entityNameLower}")
public class ${controllerName} {

    @Resource
    private ${serviceName} ${serviceNameLower};

    @ApiOperation(value = "分页查询${tableComment}")
    @PostMapping("/page")
    public R<IPage<${queryResDto}>> query${entityName}Page(@RequestBody ${queryPageReqDto} reqDto) {
        return R.ok(${serviceNameLower}.query${entityName}Page(reqDto));
    }

    @ApiOperation(value = "保存${tableComment}")
    @PostMapping("/save")
    public R<${entityName}> save(@Validated @RequestBody ${addReqDto} reqDto) {
        return R.ok(${serviceNameLower}.add${entityName}(reqDto));
    }

    @ApiOperation(value = "修改${tableComment}")
    @PostMapping("/update")
    public R<Boolean> update(@Validated @RequestBody ${updateReqDto} reqDto) {
        return ${serviceNameLower}.update${entityName}(reqDto) ? R.ok(true) : R.fail(false);
    }

    @ApiOperation(value = "批量删除${tableComment}")
    @PostMapping("/deleteBatch")
    public R<Boolean> deleteBatch(@RequestBody List<Long> ids) {
        return ${serviceNameLower}.deleteBatch(ids) ? R.ok(true) : R.fail(false);
    }
}